//
//  KLNewFeatureViewController.m
//  FamilyDoctorUser
//
//  Created by admin on 2017/11/14.
//  Copyright © 2017年 kinglian. All rights reserved.
//

#import "KLNewFeatureViewController.h"
#import "XMNavigationController.h"

static NSInteger const kImageCount = 3;

@interface KLNewFeatureViewController ()
/** 滚动视图 */
@property (strong, nonatomic) UIScrollView *scrollView;

@end

@implementation KLNewFeatureViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.automaticallyAdjustsScrollViewInsets = NO;
    [self setup];
    // Do any additional setup after loading the view.
}

- (void)setup {
    
    self.scrollView.contentSize = CGSizeMake(kScreenWidth * kImageCount, kScreenHeight);
    [self.view addSubview:self.scrollView];
    
    for (int i = 0; i < kImageCount; i++) {
        // 图片不要放在Assets.xcassets文件中
        NSString *imageName = nil;
        if (iPhone6) {
            imageName = [NSString stringWithFormat:@"guide0%d i4", i];
        }else if (iPhone5) {
            imageName = [NSString stringWithFormat:@"guide0%d i5", i];
        }else if (iPhone6) {
            imageName = [NSString stringWithFormat:@"guide0%d i6", i];
        }else {
            imageName = [NSString stringWithFormat:@"guide0%d i6p", i];
        }
        
        NSString *imagePath = [[NSBundle mainBundle] pathForResource:imageName ofType:@"png"];
        
        UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageWithContentsOfFile:imagePath]];
        imageView.frame = CGRectMake(i * kScreenWidth, 0, kScreenWidth, kScreenHeight);
        [self.scrollView addSubview:imageView];
        
        if (i == 2) {
            UIButton *enterButton = [UIButton buttonWithType:UIButtonTypeCustom];
            enterButton.frame = CGRectMake(0, 0.7 * kScreenHeight, kScreenWidth, kScreenHeight * 0.25);
            enterButton.tag = 2;
            [enterButton addTarget:self action:@selector(enterButtonClick:) forControlEvents:UIControlEventTouchUpInside];
            imageView.userInteractionEnabled = YES;
            [imageView addSubview:enterButton];
        }
        
    }
}

- (void)enterButtonClick:(UIButton *)button {
  
    NSLog(@"skfaskf;askf;laks;fkas;lfkas;lkf;laskf;laskfl;askf;laskf;laskf;l");
    
}

#pragma mark - Lazy
- (UIScrollView *)scrollView {
    if (!_scrollView) {
        UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:self.view.bounds];
        scrollView.pagingEnabled = YES;
        scrollView.bounces = NO;
        scrollView.userInteractionEnabled = YES;
        scrollView.showsHorizontalScrollIndicator = NO;
        _scrollView = scrollView;
    }
    return _scrollView;
}


@end
